/*
 *    Copyright (c) 2018-2025, boss All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the boss developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: boss
 */

package com.hopes.bizz.poll.alarm.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hopes.bizz.common.core.util.DateUtils;
import com.hopes.bizz.poll.common.constant.enums.PollModDictEnum;
import com.hopes.bizz.poll.common.loigc.AlarmLogic;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 超标报警
 *
 * @author daijie
 * @date 2023-05-29 10:28:45
 */
@Data
@TableName("poll_alarm")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "超标报警")
public class PollAlarmEntity extends BaseLogicEntity {

    private static final long serialVersionUID = 1L;


	/**
	* 标识
	*/
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description="标识")
    private Long id;

	/**
	* 监控点
	*/
    @Schema(description="监控点")
    private Long monitorSiteId;

	/**
	* 报警因子
	*/
    @Schema(description="报警因子")
    private String factorCode;

	/**
	* 报警设置值
	*/
    @Schema(description="报警设置值")
    private BigDecimal alarmConfigValue;

	/**
	* 监测值
	*/
    @Schema(description="监测值")
    private BigDecimal monitorValue;

	/**
	* 超标倍数
	*/
    @Schema(description="超标倍数")
    private BigDecimal excessMultiple;

	/**
	* 报警时间
	*/
    @Schema(description="报警时间")
    private Date alarmTime;

	/**
	* 解除时间
	*/
    @Schema(description="解除时间")
    private Date removeTime;

	/**
	* 持续时间
	*/
    @Schema(description="持续时间")
    private Long durationTime;

	/**
	* 报警级别
	*/
    @Schema(description="报警级别")
    private Integer alarmLevel;

	/**
	* 报警状态
	*/
    @Schema(description="报警状态")
    private Integer alarmStatus;

	/**
	* 处理状态
	*/
    @Schema(description="处理状态")
    private Integer handleStatus;

	/**
	* 报警内容
	*/
    @Schema(description="报警内容")
    private String alarmContent;

	/**
	* 备注
	*/
    @Schema(description="备注")
    private String remarks;
 
	/**
	* orgId
	*/
    @Schema(description="orgId")
    private Long orgId;

	public String getOrgIdStr() {
		return DictResolver.getItemLabelByValue(AdminDictEnum.sys_company, this.orgId);
	}

	public String getMonitorSiteStr() {
		return DictResolver.getItemLabelByValue(PollModDictEnum.monitor_site, this.monitorSiteId);
	}

	public String getDurationTimeDesc() {
		return AlarmLogic.buildDurationTimeDesc(this.getAlarmTime(), this.getRemoveTime(), this.getDurationTime() * 60, this.getAlarmStatus());
	}

	public String getAlarmTimeStr() {
		return DateUtils.limitMinute(this.alarmTime);
	}

	public String getRemoveTimeStr() {
		return DateUtils.limitDay(this.removeTime);
	}

	public String getFactorCodeStr() {
        return DictResolver.getItemLabelByValue(PollModDictEnum.factor_info_code, this.factorCode);
    }

	public Long getFactorId() {
		return DictResolver.getItemByValue(PollModDictEnum.factor_info_code, this.factorCode).getId();
	}

	public String getMonitorValueStr() {
		return this.monitorValue + DictResolver.getItemByValue(PollModDictEnum.factor_info_code, this.factorCode).getExt1();
	}

	public String getTownId() {
		return DictResolver.getItemLabelByValue(PollModDictEnum.monitor_site_town, this.monitorSiteId);
	}

	public String getTownIdStr() {
		return DictResolver.getItemLabelByValue(PollModDictEnum.town_info, this.getTownId());
	}
}